package com.roomio.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.roomio.dao.GroupInfoDAO;
import com.roomio.dao.TransactionsDAO;
import com.roomio.domain.GroupTransaction;
import com.roomio.domain.Transaction;
import com.roomio.domain.UserTransaction;
import com.roomio.service.TransactionsService;

@Service
@Transactional
public class TransactionServiceImpl extends BaseService implements TransactionsService{

	@Autowired
	private TransactionsDAO transactionsDAO;
	
	@Autowired
	private GroupInfoDAO groupInfoDAO;
	
	@Override
	public Transaction saveGroupTransaction(GroupTransaction transaction) {	
		transactionsDAO.save(transaction);
		return transaction;
	}
	
	@Override
	public Transaction saveUserTransaction(UserTransaction transaction) {		
		transactionsDAO.save(transaction);
		return transaction;
	}

	@Override
	public List<Transaction> findAllUserTransactions(String userName) {
		return transactionsDAO.getTransactionByUserName(userName);
	}

	@Override
	public List<Transaction> findAllGroupTransactions(Long groupId) {
		return transactionsDAO.getTransactionByGroup(groupId);
	}

	@Override
	public void update(Transaction transaction) {
		transactionsDAO.update(transaction);
		
	}

	@Override
	public void expireTransaction(Long id) {
		// TODO Auto-generated method stub
		
	}

}
